package com.thoughtworks.impersonator.http.record;

import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;

import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
import org.junit.Test;

import com.thoughtworks.impersonator.http.message.storage.HttpExchangeStorage;

public class RecorderPipelineFactoryTest {
    
    @Test
    public void shouldRegisterChunkedHttpDecoder() throws Exception {
        RecorderPipelineFactory factory = new RecorderPipelineFactory(mock(ClientBootstrap.class), mock(HttpExchangeStorage.class), 
                "somehost.com", 10000);
        
        ChannelPipeline pipeline = factory.getPipeline();
        
        assertThat(pipeline.get(HttpChunkAggregator.class), notNullValue());
    }
    
    @Test
    public void shouldRegisterClientConnectionHandler() throws Exception {
        RecorderPipelineFactory factory = new RecorderPipelineFactory(mock(ClientBootstrap.class), mock(HttpExchangeStorage.class), 
                "somehost.com", 10000);
        
        ChannelPipeline pipeline = factory.getPipeline();
        
        assertThat(pipeline.get(ClientConnectionHandler.class), notNullValue());
    }
}
